package com.example.jurisdiction.Controller;

import java.util.List;

import com.example.jurisdiction.Service.user_roleService;
import com.example.jurisdiction.dto.user_roleDto;
import entity.user_role;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;



@CrossOrigin(methods = {RequestMethod.POST,RequestMethod.GET})
@Controller
@RequestMapping("/user_role")
public class user_roleContoller {
	
	@Autowired
	private com.example.jurisdiction.Service.user_roleService user_roleService;
	
	
	@RequestMapping("/user_role.do")
	public @ResponseBody String Roles_menus(user_roleDto dto, Integer rid)throws Exception{
		System.out.println("��ɫID"+rid);
		this.user_roleService.delUser_role(rid);
		System.out.println(dto.getMenusIds().length);
		if(dto.getMenusIds().length!=0) {
			
			this.user_roleService.addUser_role(dto);
		}else {
			System.out.println("sddf");
		}
		
		return "�ɹ�";
	}
	
	@RequestMapping("/getUser.do")
	public @ResponseBody List<user_role> getUser_role(int id) throws Exception{
		
		return this.user_roleService.getUser_role(id);
		
	}
}
